<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Server热更新系统</title>

{{template "bootstrap"}}
<script>
function setRetire(level,svid, port, flag){
	if(!svid || !port) alert('serverId or port is empty...');
	$('input[name="level"]').val(level);
	$('input[name="port"]').val(port);
	$('input[name="svid"]').val(svid);
	$('input[name="flag"]').val(flag);
	if(confirm("are you sure set it?")){
		$('form').submit();
	}
}
$(function(){
	$('input[name="reflush"]').click(function(){
		location.reload();
	});
})
</script>
</head>
<body>

	{{template "nav"}}
	
	<div class="list">
		<input type="button" name="reflush" value="刷新" />
	</div>
	
	
	<form action="/retire/retire" method="post">
		<input type="hidden" name="act" value="set" />
		<input type="hidden" name="level" value="" />
		<input type="hidden" name="port" value="" />
		<input type="hidden" name="svid" value="" />
		<input type="hidden" name="flag" value="" />
	</form>
	<div class="container" style="width:800px;height:800px;  overflow-y:scroll">
		<table class="table table-hover">
			<tbody>
				<tr>
					<th>场次</th>
					<th>serverId</th>
					<th>端口</th>
					<th>在玩人数</th>
					<th>ctime</th>
					<th>状态</th>
					<th>operate</th>
				</tr>
				{{range .Allocs}}
					{{$count := .Count}}
					{{$level := .Level}}
					{{$isFirst := true}}
			
				
					{{range .GameServer}}
						<tr>
							<td>alloc_{{ $level }}</td>
							<td>{{.ServerID}}</td>
							<td>{{.Port}}</td>
							<td>{{.UserCount}}</td>
							<td>{{.CreateTime}}</td>
							{{if .Retire }}
								<td>已退休</td>
								<td><a href="javascript:void(0)" onclick="setRetire({{ $level }},{{.ServerID}},{{.Port}},0)"><font color="red">恢复</font></a></td>
					  	    {{else}}
								<td>正在运行</td>
							    <td><a href="javascript:void(0)" onclick="setRetire({{ $level }},{{.ServerID}},{{.Port}},1)"><font color="red">退休</font></a></td>
							{{end}}
					 </tr>
					{{end}}

				{{end}}
			</tbody>
		</table>
	</div>
</body>
</html>